
/*重置context
* 文件名：HttpReqRespContextInterceptor.java
* 版权：Copyright by www.ysepay.com
* 修改人：Cindy
* 修改时间：2016年4月7日
* 修改内容：
*/

package com.yspay.sample.intercepter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class HttpReqRespContextInterceptor implements HandlerInterceptor {

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {

		HttpReqRespHolder.resetHttpContext();

		HttpReqRespHolder.setHttpContext(request, response);

		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {

	}

	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {

		HttpReqRespHolder.resetHttpContext();
	}

}
